<!doctype html>
<html lang="en">
	<head>
		<title>JavaScript Patterns</title>
		<meta charset="utf-8">
	</head>
	<body>
		<script>

			function next() {
				var count = 1;
				next = function () {
					return ++count;
				};
				return count;
			}
			console.log(next()); // 1
			console.log(next()); // 2
		</script>
	</body>
</html>